using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data;
using XBLib.Dal.AdoDal;
using DataInfo;
using KenLib.Common;
namespace KenLib.Dal
{
    public class 職種職務情報Dao : BaseAdoDao
      {
          private string m_requestTime;
          private string m_displayTime;
          public int Insert(職種職務情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param1 = _daoHelper.CreateParameter("@職種コード", obj.職種コード, DbType.Int32);
                  DbParameter param2 = _daoHelper.CreateParameter("@職種", obj.職種, DbType.String);
                  DbParameter param3 = _daoHelper.CreateParameter("@職務コード", obj.職務コード, DbType.Int32);
                  DbParameter param4 = _daoHelper.CreateParameter("@職務", obj.職務, DbType.String);
                  DbParameter param5 = _daoHelper.CreateParameter("@立場", obj.立場, DbType.String);
                  DbParameter param6 = _daoHelper.CreateParameter("@具体的業務内容", obj.具体的業務内容, DbType.String);
                  DbParameter param7 = _daoHelper.CreateParameter("@実際開始日", obj.実際開始日, DbType.DateTime );
                  DbParameter param8 = _daoHelper.CreateParameter("@実際終了日", obj.実際終了日, DbType.DateTime);
                  DbParameter param9 = _daoHelper.CreateParameter("@変更理由", obj.変更理由, DbType.String);
                  DbParameter param10 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Insert_HumanCareerInfo, CommandType.StoredProcedure,param20, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "INSERT", "Insert_HumanCareerInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Update(職種職務情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", obj.ID, DbType.Int32);
                  DbParameter param1 = _daoHelper.CreateParameter("@職種コード", obj.職種コード, DbType.Int32);
                  DbParameter param2 = _daoHelper.CreateParameter("@職種", obj.職種, DbType.String);
                  DbParameter param3 = _daoHelper.CreateParameter("@職務コード", obj.職務コード, DbType.Int32);
                  DbParameter param4 = _daoHelper.CreateParameter("@職務", obj.職務, DbType.String);
                  DbParameter param5 = _daoHelper.CreateParameter("@立場", obj.立場, DbType.String);
                  DbParameter param6 = _daoHelper.CreateParameter("@具体的業務内容", obj.具体的業務内容, DbType.String);
                  DbParameter param7 = _daoHelper.CreateParameter("@実際開始日", obj.実際開始日, DbType.DateTime);
                  DbParameter param8 = _daoHelper.CreateParameter("@実際終了日", obj.実際終了日, DbType.DateTime);
                  DbParameter param9 = _daoHelper.CreateParameter("@変更理由", obj.変更理由, DbType.String);
                  DbParameter param10 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Update_HumanCareerInfo, CommandType.StoredProcedure,param20, param0, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "UPDATE", "Update_HumanCareerInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Delete(int id)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", id, DbType.Int32);

                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Delete_HumanCareerInfo, CommandType.StoredProcedure, param0);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "DELETE", "Delete_HumanCareerInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          #region Code Hunglt
		  public string Insert職種職務情報(職種職務情報 obj) 
          {
              try
              {
                  DbParameter param廃止区分 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbParameter param立場 = _daoHelper.CreateParameter("@立場", obj.立場, DbType.String);
                  DbParameter param具体的業務内容 = _daoHelper.CreateParameter("@具体的業務内容", obj.具体的業務内容, DbType.String);
                  DbParameter param職種コード = _daoHelper.CreateParameter("@職種コード", obj.職種コード.ToString(), DbType.String);
                  DbParameter param職種 = _daoHelper.CreateParameter("@職種", obj.職種, DbType.String);
                  DbParameter param職務コード = _daoHelper.CreateParameter("@職務コード", obj.職務コード.ToString(), DbType.String);
                  DbParameter param職務 = _daoHelper.CreateParameter("@職務", obj.職務, DbType.String);
                  DbParameter param実際開始日 = _daoHelper.CreateParameter("@実際開始日", obj.実際開始日, DbType.DateTime);

                  DbCommand command = _daoHelper.CreateCommand("sp_Insert_FrmO_EmpCareerInput_Hunglt", CommandType.StoredProcedure,
                      param廃止区分, param社員ID, param立場, param具体的業務内容, param職種コード, param職種, 
                      param職務コード, param職務, param実際開始日);
				  return _daoHelper.ExecuteScalar(command).ToString();
              }
              catch (Exception)
              {
                  throw;
              }
          }
		  public void UpdateInfo職種職務情報_FrmO_ByID(職種職務情報 obj, int ID)
		  {
			  DbParameter dbParamID = _daoHelper.CreateParameter("@ID", ID, DbType.Int32);
			  DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
			  DbParameter param立場 = _daoHelper.CreateParameter("@立場", obj.立場, DbType.String);
			  DbParameter param具体的業務内容 = _daoHelper.CreateParameter("@具体的業務内容", obj.具体的業務内容, DbType.String);
			  DbParameter param職種コード = _daoHelper.CreateParameter("@職種コード", obj.職種コード.ToString(), DbType.String);
			  DbParameter param職種 = _daoHelper.CreateParameter("@職種", obj.職種, DbType.String);
			  DbParameter param職務コード = _daoHelper.CreateParameter("@職務コード", obj.職務コード.ToString(), DbType.String);
			  DbParameter param職務 = _daoHelper.CreateParameter("@職務", obj.職務, DbType.String);
			  DbParameter param実際開始日 = _daoHelper.CreateParameter("@実際開始日", obj.実際開始日, DbType.DateTime);

			  DbCommand dbcommand = _daoHelper.CreateCommand("sp_update_職種職務情報_FormO_Hunglt", CommandType.StoredProcedure,
				 dbParamID, param社員ID, param立場, param具体的業務内容, param職種コード, param職種, param職務コード, param職務, param実際開始日);
			  _daoHelper.Execute(dbcommand);
		  }
          public DataTable SelectData職種職務情報(int @社員ID)
          {
              DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
              DbCommand command = _daoHelper.CreateCommand("sp_select_職種職務情報_Hunglt", CommandType.StoredProcedure, param社員ID);
              return _daoHelper.Query(command);
          }
          public void UpdateInfo職種職務情報(職種職務情報 obj)
          {
              DbParameter param廃止区分 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int32);
              DbParameter param職種コード   = _daoHelper.CreateParameter("@職種コード", obj.職種コード, DbType.Int32);
              DbParameter param職種         = _daoHelper.CreateParameter("@職種", obj.職種, DbType.String);
              DbParameter param職務コード   = _daoHelper.CreateParameter("@職務コード", obj.職務コード, DbType.Int32);
              DbParameter param職務         = _daoHelper.CreateParameter("@職務", obj.職務, DbType.String);
              DbParameter param社員ID       = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);

              DbCommand command = _daoHelper.CreateCommand("sp_update_職種職務情報_FormJ_Hunglt", CommandType.StoredProcedure,
                    param廃止区分, param職種コード, param職種, param職務コード, param職務, param社員ID);
              _daoHelper.Query(command);
          }
		  public DataTable SelectInfo職種職務情報_ByID(int ID, int 社員ID)
		  {
			  DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
			  DbParameter paramID = _daoHelper.CreateParameter("@ID", ID, DbType.Int32);

			  DbCommand command = _daoHelper.CreateCommand("sp_select_職種職務情報_FrmO_Hunglt", CommandType.StoredProcedure, param社員ID, paramID);
			  return _daoHelper.Query(command);
		  }
          #endregion
          #region TUNG
          public DataTable Get職種職務情報(int 社員ID)
          {
              DbParameter param1 = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
              DbCommand command = _daoHelper.CreateCommand("sp_Get職種職務情報_TUNG", CommandType.StoredProcedure, param1);
              return _daoHelper.Query(command);
          }
          #endregion


          #region Phuong
          public void Insert職種職務情報_Phuong(職種職務情報 obj)
          {
              DbParameter param1 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
              DbParameter param2 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int32);
              DbParameter param3 = _daoHelper.CreateParameter("@職種コード", obj.職種コード, DbType.Int32);
              DbParameter param4 = _daoHelper.CreateParameter("@職種", obj.職種, DbType.String);
              DbParameter param5 = _daoHelper.CreateParameter("@職務コード", obj.職務コード, DbType.Int32);
              DbParameter param6 = _daoHelper.CreateParameter("@職務", obj.職務, DbType.String);
              DbParameter param7 = _daoHelper.CreateParameter("@立場", obj.立場, DbType.String);
              DbParameter param8 = _daoHelper.CreateParameter("@具体的業務内容 ", obj.具体的業務内容, DbType.String);
              DbParameter param9 = _daoHelper.CreateParameter("@実際開始日", obj.実際開始日, DbType.DateTime);
              DbParameter param10 = _daoHelper.CreateParameter("@実際終了日", obj.実際終了日, DbType.DateTime);
              DbParameter param11 = _daoHelper.CreateParameter("@変更理由 ", (obj.変更理由 == "") ? null : obj.変更理由, DbType.String);
              DbCommand command = _daoHelper.CreateCommand(CommandNameManager.sp_frmJ_StaffCareerInput_Insert_Phuong, CommandType.StoredProcedure, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11);
              _daoHelper.Execute(command);
          }
          public void Update職種職務情報(職種職務情報 obj)
          {
              DbParameter param1 = _daoHelper.CreateParameter("@ID", obj.ID, DbType.Int32);
              DbParameter param2 = _daoHelper.CreateParameter("@職種コード", obj.職種コード, DbType.Int32);
              DbParameter param3 = _daoHelper.CreateParameter("@職種", obj.職種, DbType.String);
              DbParameter param4 = _daoHelper.CreateParameter("@職務コード", obj.職務コード, DbType.Int32);
              DbParameter param5 = _daoHelper.CreateParameter("@職務", obj.職務, DbType.String);
              DbParameter param6 = _daoHelper.CreateParameter("@立場", obj.立場, DbType.String);
              DbParameter param7 = _daoHelper.CreateParameter("@具体的業務内容 ", obj.具体的業務内容, DbType.String);
              DbParameter param8 = _daoHelper.CreateParameter("@実際開始日", obj.実際開始日, DbType.DateTime);
              DbParameter param9 = _daoHelper.CreateParameter("@実際終了日", obj.実際終了日, DbType.DateTime);
              DbParameter param10 = _daoHelper.CreateParameter("@変更理由 ", (obj.変更理由 == "") ? null : obj.変更理由, DbType.String);
              DbCommand command = _daoHelper.CreateCommand(CommandNameManager.sp_frmJ_StaffCareerInput_Update_Phuong, CommandType.StoredProcedure, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10);
              _daoHelper.Execute(command);
          }
          public DataTable Get職種職務情報ById(int ID)
          {
              DbParameter param1 = _daoHelper.CreateParameter("@ID",ID, DbType.Int32);
              DbCommand command = _daoHelper.CreateCommand(CommandNameManager.sp_frmJ_StaffCareerInput_Get職種職務情報ById_Phuong, CommandType.StoredProcedure, param1);
              return _daoHelper.Query(command);
          }
          public DataTable Get職種職務情報By社員ID(int 社員ID)
          {
              DbParameter param1 = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
              DbCommand command = _daoHelper.CreateCommand(CommandNameManager.sp_frmJ_StaffCareerInput_GetBy社員ID_Phuong, CommandType.StoredProcedure, param1);
              return _daoHelper.Query(command);
          }
          public DataTable checkDLL(int ID1, int ID2, int ManNhanVien)
          {
              DbParameter param1 = _daoHelper.CreateParameter("@ID1", ID1, DbType.Int32);
            
              DbParameter param2 = _daoHelper.CreateParameter("@ID2", ID2, DbType.Int32);
              DbParameter param3 = _daoHelper.CreateParameter("@ManNhanVien", ManNhanVien, DbType.Int32);

              DbCommand command = _daoHelper.CreateCommand("sp_frmJ_StaffCareerInput_checkDLL_Phuong", CommandType.StoredProcedure, param1, param2, param3);
              return _daoHelper.Query(command);
          }
          public DataTable select職種職務情報ByID(int 社員ID)
          {
              DbParameter param1 = _daoHelper.CreateParameter("@ID", 社員ID, DbType.Int32);
              DbCommand command = _daoHelper.CreateCommand("getAll職種職務情報ByID_luclt", CommandType.StoredProcedure, param1);
              return _daoHelper.Query(command);
          }

          #endregion
      }
}
